<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>5、两栋颜色不同且距离最远的房子</title>
</head>

<body>
  <script>
    let arr = [{
      house: '0',
      color: 'blue'
    },
    {
      house: '1',
      color: 'blue'
    },
    {
      house: '2',
      color: 'blue'
    },
    {
      house: '3',
      color: 'red'
    },
    {
      house: '4',
      color: 'red'
    },
    {
      house: '5',
      color: 'blue'
    }]
    var max = 0;
    for (var i = 0; i < arr.length; i++) {
      for (var b = arr.length - 1; b > i; b--) {
        if (arr[i].color != arr[b].color) {
          var sum = b - i;
          if (sum > max) {
            max = sum
          }
        }
      }
    }
    console.log(max)

    // let obj1 = `{
    //   house: '1',
    //   color: 'red'
    // }`
    // let obj2 = `{
    //   house: '1',
    //   color: 'red'
    // }`
    // console.log(obj1 == obj2);
  </script>
</body>

</html>